*** This do file makes event study graphs Figure B2 for the minimum wage precommittment paper
*** using the year of first statutory increase as the first treatment year


*** Last updated: 12/6/2021

set more off
capture log close
clear all
* If needed change global path to point to directory where files are stored on your computer
*global path "I:/DataSets5/Duncan/Dropbox/Recent Minimum Wage Changes/2020.12 NBER Update/JOLE Precommittment Replication"
global dtadir "$path/Data"
global tabdir "$path/Tables"
global figdir "$path/Figures"
global estdir "$path/Estimates"
global logdir "$path/Logfiles"

log using "$logdir/event-study-graphs-no-categories-drop-indexers.log", replace

**** LOW-SKILLED INDIVIDUALS AGES 16-25 WITH LESS THAN A COMPLETED HIGH-SCHOOL EDUCATION

*** Panel A: Low-Skilled No Controls
use "$estdir/EventTime/EventTimeRegressionEmploymentLeastNoControls.dta", clear

* Manually add 0 for event time zero zero is the baseline period for the event study
replace parm = "eventtimeNOIzero" if parm == "_cons"
replace estimate = 0 if parm == "eventtimeNOIzero"
replace max95 = 0 if parm == "eventtimeNOIzero"
replace min95 = 0 if parm == "eventtimeNOIzero"


* Generate eventtime variable
gen eventtime =.
replace eventtime = -4 if substr(parm,-8,.) == "neg4plus"
replace eventtime = -3 if substr(parm,-8,.) == "neg3plus"
replace eventtime = -2 if substr(parm,-4,.) == "neg2"
replace eventtime = -1 if substr(parm,-4,.) == "neg1"
replace eventtime = 0 if substr(parm,-4,.) == "zero"
replace eventtime = 1 if substr(parm,-4,.) == "pos1"
replace eventtime = 2 if substr(parm,-4,.) == "pos2"
replace eventtime = 3 if substr(parm,-4,.) == "pos3"
replace eventtime = 4 if substr(parm,-8,.) == "pos4plus"

drop if eventtime ==.

sort eventtime

graph twoway (scatter estimate eventtime, msymbol(circle) mcolor(black)) || (rspike min95 max95 eventtime, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel A: Low-Skilled with No Controls", size(medsmall) color(black)) legend(region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeLeastNoControls, replace)

*** Panel B: Low-Skilled Sparse Controls
use "$estdir/EventTime/EventTimeRegressionEmploymentLeastBaseControls.dta", clear

* Manually add 0 for event time zero zero is the baseline period for the event study
replace parm = "eventtimeNOIzero" if parm == "_cons"
replace estimate = 0 if parm == "eventtimeNOIzero"
replace max95 = 0 if parm == "eventtimeNOIzero"
replace min95 = 0 if parm == "eventtimeNOIzero"


* Generate eventtime variable
gen eventtime =.
replace eventtime = -4 if substr(parm,-8,.) == "neg4plus"
replace eventtime = -3 if substr(parm,-8,.) == "neg3plus"
replace eventtime = -2 if substr(parm,-4,.) == "neg2"
replace eventtime = -1 if substr(parm,-4,.) == "neg1"
replace eventtime = 0 if substr(parm,-4,.) == "zero"
replace eventtime = 1 if substr(parm,-4,.) == "pos1"
replace eventtime = 2 if substr(parm,-4,.) == "pos2"
replace eventtime = 3 if substr(parm,-4,.) == "pos3"
replace eventtime = 4 if substr(parm,-8,.) == "pos4plus"

drop if eventtime ==.

sort eventtime

graph twoway (scatter estimate eventtime, msymbol(circle) mcolor(black)) || (rspike min95 max95 eventtime, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel B: Low-Skilled with Sparse Controls", size(medsmall) color(black)) legend(order(1) label(1 "All Statutory Increasers") region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeLeastBaseControls, replace)

*** Panel C: Low-Skilled Rich Controls
use "$estdir/EventTime/EventTimeRegressionEmploymentLeastRichControls.dta", clear

* Drop unneded variables
drop if substr(parm,1,1) == "D"

* Manually add 0 for the baseline period in the event study
replace parm = "eventtimeNOIzero" if parm == "_cons"
replace estimate = 0 if parm == "eventtimeNOIzero"
replace max95 = 0 if parm == "eventtimeNOIzero"
replace min95 = 0 if parm == "eventtimeNOIzero"


* Generate eventtime variable
gen eventtime =.
replace eventtime = -4 if substr(parm,-8,.) == "neg4plus"
replace eventtime = -3 if substr(parm,-8,.) == "neg3plus"
replace eventtime = -2 if substr(parm,-4,.) == "neg2"
replace eventtime = -1 if substr(parm,-4,.) == "neg1"
replace eventtime = 0 if substr(parm,-4,.) == "zero"
replace eventtime = 1 if substr(parm,-4,.) == "pos1"
replace eventtime = 2 if substr(parm,-4,.) == "pos2"
replace eventtime = 3 if substr(parm,-4,.) == "pos3"
replace eventtime = 4 if substr(parm,-8,.) == "pos4plus"

drop if eventtime ==.

sort eventtime

graph twoway (scatter estimate eventtime, mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 eventtime, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel C: Low-Skilled with Rich Controls", size(medsmall) color(black)) legend(order(1) label(1 "All Statutory Increasers") region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeLeastRichControls, replace)
*graph export "$estdir/Output\Event Study Graphs\EventTime\EventTimeLeastRichControls.pdf", as(pdf) replace

*** Panel D: Young No Controls
use "$estdir/EventTime/EventTimeRegressionEmploymentYoungNoControls.dta", clear

* Manually add 0 for the baseline period in the event study
replace parm = "eventtimeNOIzero" if parm == "_cons"
replace estimate = 0 if parm == "eventtimeNOIzero"
replace max95 = 0 if parm == "eventtimeNOIzero"
replace min95 = 0 if parm == "eventtimeNOIzero"


* Generate eventtime variable
gen eventtime =.
replace eventtime = -3 if substr(parm,-8,.) == "neg3plus"
replace eventtime = -2 if substr(parm,-4,.) == "neg2"
replace eventtime = -1 if substr(parm,-4,.) == "neg1"
replace eventtime = 0 if substr(parm,-4,.) == "zero"
replace eventtime = 1 if substr(parm,-4,.) == "pos1"
replace eventtime = 2 if substr(parm,-4,.) == "pos2"
replace eventtime = 3 if substr(parm,-4,.) == "pos3"
replace eventtime = 4 if substr(parm,-8,.) == "pos4plus"

drop if eventtime ==.

sort eventtime

graph twoway (scatter estimate eventtime, mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 eventtime, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel D: Young with No Controls", size(medsmall) color(black)) legend(order(1) label(1 "All Statutory Increasers") region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeYoungNoControls, replace)

*** Panel E: Young Sparse Controls
use "$estdir/EventTime/EventTimeRegressionEmploymentYoungBaseControls.dta", clear

* Manually add 0 for the baseline period in the event study
replace parm = "eventtimeNOIzero" if parm == "_cons"
replace estimate = 0 if parm == "eventtimeNOIzero"
replace max95 = 0 if parm == "eventtimeNOIzero"
replace min95 = 0 if parm == "eventtimeNOIzero"


* Generate eventtime variable
gen eventtime =.
replace eventtime = -3 if substr(parm,-8,.) == "neg3plus"
replace eventtime = -2 if substr(parm,-4,.) == "neg2"
replace eventtime = -1 if substr(parm,-4,.) == "neg1"
replace eventtime = 0 if substr(parm,-4,.) == "zero"
replace eventtime = 1 if substr(parm,-4,.) == "pos1"
replace eventtime = 2 if substr(parm,-4,.) == "pos2"
replace eventtime = 3 if substr(parm,-4,.) == "pos3"
replace eventtime = 4 if substr(parm,-8,.) == "pos4plus"

drop if eventtime ==.

sort eventtime

graph twoway (scatter estimate eventtime, mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 eventtime, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel E: Young with Sparse Controls", size(medsmall) color(black)) legend(order(1) label(1 "All Statutory Increasers") region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeYoungBaseControls, replace)


*** Panel F: Young Rich Controls
use "$estdir/EventTime/EventTimeRegressionEmploymentYoungRichControls.dta", clear

* Drop unneded variables
drop if substr(parm,1,1) == "D"

* Manually add 0 for the baseline period in the event study
replace parm = "eventtimeNOIzero" if parm == "_cons"
replace estimate = 0 if parm == "eventtimeNOIzero"
replace max95 = 0 if parm == "eventtimeNOIzero"
replace min95 = 0 if parm == "eventtimeNOIzero"

* Generate eventtime variable
gen eventtime =.
replace eventtime = -3 if substr(parm,-8,.) == "neg3plus"
replace eventtime = -2 if substr(parm,-4,.) == "neg2"
replace eventtime = -1 if substr(parm,-4,.) == "neg1"
replace eventtime = 0 if substr(parm,-4,.) == "zero"
replace eventtime = 1 if substr(parm,-4,.) == "pos1"
replace eventtime = 2 if substr(parm,-4,.) == "pos2"
replace eventtime = 3 if substr(parm,-4,.) == "pos3"
replace eventtime = 4 if substr(parm,-8,.) == "pos4plus"

drop if eventtime ==.

sort eventtime

graph twoway (scatter estimate eventtime, mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 eventtime, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel F: Young with Rich Controls", size(medsmall) color(black)) legend(order(1) label(1 "All Statutory Increasers") region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeYoungRichControls, replace)


* Combine graphs to make a 6-panel figure
set graph on
graph dir // These named graphs are now in memory


grstyle init
grstyle color background white
grstyle graphsize x 20
grstyle graphsize y 11
grstyle set legend, nobox

* Combined employment graph
grc1leg2 EventTimeLeastNoControls EventTimeLeastBaseControls EventTimeLeastRichControls ///
EventTimeYoungNoControls EventTimeYoungBaseControls EventTimeYoungRichControls,  ///
	l1("Change", size(medsmall) color(black)) b1("Event Time", size(medsmall) color(black)) ring(2) xsize(20) ysize(11) margins(tiny) ///
	graphregion(color(white)) legendfrom(EventTimeLeastNoControls) lsize(medsmall)
graph save "$figdir/event-time-event-study-figure-no-categories-drop-all-indexers.gph", replace
graph export "$figdir/event-time-event-study-figure-no-categories-drop-all-indexers.pdf", as(pdf) replace

